package com.example.springboot.oauth2;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * ========================
 */
@Component
@Aspect
public class AutoAop {

    private final Logger log = LoggerFactory.getLogger(getClass());

    @Around("@annotation(requestMapping)")
    public Object authAround(ProceedingJoinPoint joinPoint, RequestMapping requestMapping) throws Throwable
    {
        Object result = joinPoint.proceed();
        //System.out.println(result);
        log.info("authAround>>",result);
        return result;
    }


    @AfterReturning(pointcut = "execution(* org.springframework.security.oauth2.*.*(..))")
    public void afterReturning(JoinPoint joinPoint) {
        //System.out.println("[Aspect1] afterReturning advise");
        log.info("afterReturning>>",joinPoint);
    }
}
